package com.example.budget3.recurring;



import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public class RecurrDeleteDialogFragment extends DialogFragment {
	
	public static final String KEY_LIST_PREFERENCE = "pref_currency";
	private int position;
	RecurrListFragment parentFragment;
	@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        getActivity().getLayoutInflater();
    	
    	position = getArguments().getInt("position");
    	
    	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    	parentFragment = (RecurrListFragment) getTargetFragment();

		builder.setMessage("Are you sure you want to remove this item?")
				.setTitle("Remove Item");
		builder.setPositiveButton("Ok",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int id) {

						
						 parentFragment.removeItem(position);
					}
				});
		builder.setNegativeButton("Cancel",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int id) {
					}
				});

		AlertDialog dialog = builder.create();
		dialog.show();
	
		return dialog;

    }

}
